package com.test.springmvc;



import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;


@Controller
public class RedirectCtrl {

    @RequestMapping(value = "/forward")
    public ModelAndView forward(ModelAndView modelAndView){
        modelAndView.addObject("username","admin");
        modelAndView.addObject("email","yyy@qq.com");
        modelAndView.addObject("age","23");
        modelAndView.setViewName("forward:jsp/login.jsp");

        return modelAndView;
    }

    @RequestMapping(value = "/redirect")
    public String redirect(){

        return "redirect:jsp/login.jsp";
    }

    @RequestMapping(value = "/test4")
    public String test4(HttpServletRequest request){
        request.setAttribute("123213","sdfdsf");
        String str="tttt";
        return "redirect:test5.shtml?id=" + str;
    }

    @RequestMapping(value = "/test5")
    public String test5(HttpServletRequest request){
        String id = (String)request.getParameter("id");
        System.out.println(id);
        return "suess";
    }
}
